/**
 * Created with IntelliJ IDEA.
 * Description:Day11 - Day16
 * User: mac
 * Date: 2022-08-26
 * Time: 17:07
 */
public class WorkDemo {
    //Day11

    //1.D 2.A 3.C 4.A 5.A
    //6.最大连续1的个数
    public int findMaxConsecutiveOnes(int[] nums) {
        int count = 0;
        int ret = 1;
        for (int i = 0; i <= nums.length - 1; i++) {
            int j = i;
            if (nums[j] == 1){
                while (j < nums.length - 1 && nums[j] == nums[j + 1]){
                    ret++;
                    j++;
                }
                if (ret > count){
                    count = ret;
                }
                ret = 1;
                j = 0;
            }
        }
        return count;
    }
    //7.完全数
    public static int perfectNumber(int n){
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int ret = i;
            int sum = 0;
            for (int j = 1; j <= ret / 2; j++) {
                if (ret % j == 0){
                    sum += j;
                }
            }
            if (sum == ret){
                count++;
            }
            sum = 0;
        }
        return count;
    }

    public static void main(String[] args) {
        System.out.println(perfectNumber(1000));
    }

}
